import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ui_demo/local_storage/sp_test.dart';
import 'package:ui_demo/local_storage/sp_util.dart';

import 'sp_logic.dart';

class SpComponent extends StatefulWidget {
  const SpComponent({Key? key}) : super(key: key);

  @override
  State<SpComponent> createState() => _SpComponentState();
}

class _SpComponentState extends State<SpComponent> {
  final logic = Get.put(SpLogic());

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          TextButton(
              onPressed: () {
                SpUtil.setLocalStorage("name", "Gerry Tang");
              },
              child: Text("Save Date")),
          TextButton(
              onPressed: () {
                var name = SpUtil.getLocalStorage("name");
                logger.i("name:$name");
                logger.i("name:$name");
              },
              child: Text("Read Date")),
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<SpLogic>();
    super.dispose();
  }
}
